#include<bits/stdc++.h>
using namespace std;
int l,r,k,n;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&l,&r);
	if(l==r)printf("%d",r%n);
	else if(l-r>=n)printf("%d",n-1);
	else
	{
		int u=r/n*n;
		if(u>l&&u<=r)printf("%d",n-1);
		else
			printf("%d",r%n);
	}
	return 0;
 } 
